package com.a3dweijing.wetouch2.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.a3dweijing.wetouch2.Common.listview.CommonListviewAdapter;
import com.a3dweijing.wetouch2.Common.listview.ViewHolderListview;
import com.a3dweijing.wetouch2.R;
import com.a3dweijing.wetouch2.bean.MarketItem;

import java.util.List;

/**
 * Created by Administrator on 2018/4/2.
 */

public class MarKetAdapter extends CommonListviewAdapter
{
    public MarKetAdapter(Context context, List list, int layoutId)
    {
        super(context, list, layoutId);
    }
    
    @Override
    public void convert(ViewHolderListview holder, Object o, int position)
    {
        MarketItem.ListBean item = (MarketItem.ListBean)o;
        TextView time_top = holder.getView(R.id.time_top);
        TextView time_bottom = holder.getView(R.id.time_bottom);
        ImageView dian = holder.getView(R.id.dian);
        View dian_top = holder.getView(R.id.dian_top);
        View dian_buttom = holder.getView(R.id.dian_buttom);
        TextView content = holder.getView(R.id.content);
        String[] split = item.getTime().split(" ");
        if (split.length == 2)
        {
            time_top.setText(split[0]);
            time_bottom.setText(split[1]);
        }
        content.setText(item.getStatus());
        if (position == 0)
        {
            dian.setImageDrawable(context.getDrawable(R.drawable.market_top));
            dian_top.setVisibility(View.GONE);
            dian_buttom.setVisibility(View.VISIBLE);
        }
        else if (position == list.size() - 1)
        {
            dian.setImageDrawable(context.getDrawable(R.drawable.market_top));
            dian_buttom.setVisibility(View.GONE);
            dian_top.setVisibility(View.VISIBLE);
        }
        else
        {
            dian_buttom.setVisibility(View.VISIBLE);
            dian_top.setVisibility(View.VISIBLE);
            dian.setImageDrawable(context.getDrawable(R.drawable.market_dian));
        }
    }
}
